//
//  SingleHeartRateViewModel.swift
//  DaRings
//
//  Created by 尹琼 on 2022/11/22.
//

import UIKit
import MYModule

open class SingleHeartRateDetailModel: NSObject {
    
    // 心率
    public let heartRateModel: SingleHeartRateModel
    
    /// 设定的最大心率值
    public let maxHeartRate: Int

    /// 进度 数组
    public let progressArray: [CGFloat]
    

   public init(heartRateModel: SingleHeartRateModel) {
       
       self.heartRateModel = heartRateModel
       
       let userModel = UserCacheManagement.userInfo()
       let rate = userModel.defaultMaxHR
       
       self.maxHeartRate = rate
       
       let ageMaxHeartRate = AgeMaxHeartRate(maxHeartRate: CGFloat(rate))
       self.progressArray = ageMaxHeartRate.array
       
       super.init()
   }
    
}

extension SingleHeartRateDetailModel {
    
   public struct AgeMaxHeartRate {
        
       public var light: CGFloat
       public var weight: CGFloat
       public var aerobic: CGFloat
       public var anerobic: CGFloat
       public var max: CGFloat
       

       public var array: [CGFloat] {
           return [light, weight, aerobic, anerobic, max]
       }
       
       public init(maxHeartRate: CGFloat) {
           
           light = maxHeartRate * 0.6
           weight = maxHeartRate * 0.7
           aerobic = maxHeartRate * 0.8
           anerobic = maxHeartRate * 0.9
           max = maxHeartRate
           
       }
        
    }
    
}
